package com.wanmait.schedule.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.schedule.entity.ClassMerge;
import com.wanmait.schedule.mapper.ClassMergeMapper;
import com.wanmait.schedule.service.ClassMergeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 合班表 服务实现类
 * </p>
 *
 * @author wanmait
 * @since 2022-12-05
 */
@Service
public class ClassMergeServiceImpl extends ServiceImpl<ClassMergeMapper, ClassMerge> implements ClassMergeService {
    @Resource
    private ClassMergeMapper classMergeMapper;
    @Override
    public PageInfo<ClassMerge> list(ClassMerge classMerge,Integer pageNum){
        if(pageNum==null){
            pageNum=1;
        }
        PageHelper.startPage(pageNum,5);
        List<ClassMerge> classMergeList = classMergeMapper.list(classMerge);
        PageInfo<ClassMerge> pageInfo = new PageInfo<>(classMergeList,7);
        return pageInfo;
    }
    @Override
    public ClassMerge findById(Integer id){
        return classMergeMapper.findById(id);
    }
    @Override
    public void updateClassesStudentCount(Integer count,Integer oldId,Integer newId){

        classMergeMapper.updateClassesStudentCount(count,newId);
        classMergeMapper.updateClassesMerge(oldId);
        classMergeMapper.updateStudentCount(newId,oldId);

    }
}
